﻿namespace FiftyOne.Foundation.Mobile.Detection.Wurfl.Handlers
{
    using FiftyOne.Foundation.Mobile.Detection.Wurfl;
    using System;
    using System.Text.RegularExpressions;

    internal class MSIEDesktopHandler : MSIEHandler
    {
        private const string DEFAULT_DEVICE = "msie";
        private const byte EXTRA_CONFIDENCE = 1;
        private static readonly string[] SUPPORTED_ROOT_DEVICES = new string[] { "msie" };

        protected internal override bool CanHandle(string userAgent)
        {
            return (((userAgent.Contains("MSIE") && !userAgent.Contains("IEMobile")) && !userAgent.Contains("Windows CE")) && ((((userAgent.Contains("Windows XP") || userAgent.Contains("Windows NT")) || (userAgent.Contains("Windows ME") || userAgent.Contains("Win32"))) || ((Regex.IsMatch(userAgent, @"Windows [\d.]+") || Regex.IsMatch(userAgent, @"Windows NT [\d.]+")) || userAgent.Contains("Mac_PowerPC"))) || userAgent.Contains("PPC Mac OS")));
        }

        internal override byte Confidence
        {
            get
            {
                return (byte) (base.Confidence + 1);
            }
        }

        internal override DeviceInfo DefaultDevice
        {
            get
            {
                DeviceInfo deviceInfoFromID = Provider.Instance.GetDeviceInfoFromID("msie");
                if (deviceInfoFromID != null)
                {
                    return deviceInfoFromID;
                }
                return base.DefaultDevice;
            }
        }

        protected override string[] SupportedRootDeviceIds
        {
            get
            {
                return SUPPORTED_ROOT_DEVICES;
            }
        }
    }
}

